using System;

namespace MFGps.Devices
{
    public static class DeviceFactory
    {
        public static IGpsDevice GetGpsDevice(GpsDeviceType type)
        {
            switch (type)
            {
                case GpsDeviceType.SirfStarIII:
                    return new SirfStarIII();
                case GpsDeviceType.MediaTek:
                    return new MediaTek();
                case GpsDeviceType.uBloxNmea:
                    return new uBloxNmea();
                case GpsDeviceType.uBloxUBX:
                    throw new NotSupportedException();
                default:
                    throw new NotSupportedException();
            }
        }

        public static IGpsDevice GetGpsDevice(GpsDeviceType type, string com)
        {
            switch (type)
            {
                case GpsDeviceType.SirfStarIII:
                    return GetGpsDevice(type, com, 4800);
                case GpsDeviceType.MediaTek:
                    return GetGpsDevice(type, com, 9600);
                case GpsDeviceType.uBloxNmea:
                    return GetGpsDevice(type, com, 0); // unknown baud at this stage.
                case GpsDeviceType.uBloxUBX:
                    throw new NotSupportedException();
                default:
                    throw new NotSupportedException();
            }

            return null;
        }

        public static IGpsDevice GetGpsDevice(GpsDeviceType type, string com, int baudRate)
        {
            switch (type)
            {
                case GpsDeviceType.SirfStarIII:
                    return new SirfStarIII(com, baudRate);
                case GpsDeviceType.MediaTek:
                    return new MediaTek(com, baudRate);
                case GpsDeviceType.uBloxNmea:
                    return new uBloxNmea(com, baudRate); // unknown baud
                case GpsDeviceType.uBloxUBX:
                    throw new NotSupportedException();
                default:
                    throw new NotSupportedException();
            }
        }
    }
}
